const path = require('path');
const fs = require('fs');
module.exports = app => {
    const exports = {};

    exports.api = {
        base: 'http://192.168.1.145:8081',
        im: 'http://192.168.1.145:7080',
        // base: 'http://192.168.1.112:8084',
        // base: 'http://192.168.1.200:7081',
        common: 'http://common.zzyuu.com',
        static: '',
        image: 'http://img-test.zzyuu.com',
    };

    exports.siteFile = {
        '/favicon.ico': fs.readFileSync(path.join(app.baseDir, 'app/web/asset/images/favicon.ico'))
    };

    exports.view = {
        cache: false
    };

    exports.vuessr = {
        layout: path.join(app.baseDir, 'app/web/view/layout.html')
    };

    exports.logger = {
        consoleLevel: 'DEBUG',
        dir: path.join(app.baseDir, 'logs')
    };

    exports.security = {
        csrf: {
            enable: false,
        },
    };

    exports.static = {
        prefix: '/public/',
        dir: path.join(app.baseDir, 'public')
    };

    exports.redis = {
        client: {
            host: '192.168.1.200',
            db: 10,
            port: 6379,
            password: 'wd123456'
        }
    };

    exports.session = {
        key: 'wd:sess',
        prefix: 'koa:sess:',
        maxAge: 60 * 60 * 1000, // ms
        httpOnly: true,
        encrypt: true,
        rolling: true
    };

    exports.keys = '123456';

    exports.middleware = [
        'im',
        'guardian',
        'access',
        'auth',
        'errorHandler'
    ];

    exports.im = {
        match: [
            '/im/**'
        ]
    };

    exports.guardian = {
        match: [
            '/guardian/**'
        ]
    };

    exports.auth = {
        ignore: [
            '/login',
            '/sms/send',
            '/authorization',
            '/im/**'
        ]
    };

    return exports;
};
